"""
文件: LoginPage.py
作用: 封装ECShop登录页面
"""

from time import sleep
from common.Base import Base, open_browser
from selenium.webdriver.common.by import By

class LoginPage(Base):
    # TODO 表现层: 制作每个元素的定位器
    _username_loc = (By.NAME, "username")  # 用户名输入框
    _password_loc = (By.NAME, "passwprd")  # 密码输入框
    _submit_loc = (By.NAME, "submit")  # 立即登录按钮
    _remember_loc = (By.ID, "remember")  # 记住密码

    # TODO 操作层: 对每个元素进行的操作
    def input_username(self, username):
        """"
        输入用户名
        :param username:用户名
        :return:
        """
        self.send_keys(self._username_loc, username)

    def input_password(self, password):
        """
        输入密码
        :param password: 密码
        :return:
        """
        self.click(self._remember_loc)

    def click_submit(self):
        """
        点击立即登录按钮
        :return:
        """
        self.click(self._submit_loc)

if __name__ == "__main__":
    login = LoginPage(open_browser())